package com.sping_boot3.spirng_boot3.controller;

import lombok.Data;

import java.util.LinkedList;


@Data
public class MyLinkedList<E> {



     Node<E> first;

    /**
     * Pointer to last node.
     */
     Node<E> last;

    private static class Node<E> {
        E item;
       Node<E> next;
       Node<E> prev;

        Node(Node<E> prev, E element, Node<E> next) {
            this.item = element;
            this.next = next;
            this.prev = prev;
        }
    }

    void add(E e) {
        final Node<E> prev = last;
        final Node<E> newNode = new Node<>(prev, e, null);
        last = newNode;
        if (prev == null)
            first = newNode;
        else
            prev.next = newNode;
        System.out.println("1");
    }
}
